﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using Npgsql;
using NpgsqlTypes;



namespace appLibrary
{
   public class ConnectionDB
    {
        public NpgsqlConnection Connecction()
        {
            string MyConString="";
            string  strUser="", strDatabase="", strPort="",strServer="", strPWD="";
            if(ClassRead.readXML("config.xml",ref strServer,ref strPort,ref strDatabase,ref  strUser,ref strPWD)){
           

                MyConString = "Server="+strServer+"; DATABASE=" +strDatabase+
                    "; UID=" +strUser+"; pwd="+strPWD+";";
                //Log.eLog("uknow", "Cadena de Conexion:" + MyConString);
            }else{
                Log.eLog("uknow", "no se pudo leer el archvio de configuración");
                return null;
            }
            NpgsqlConnection connection = new NpgsqlConnection(MyConString);

                return connection;
            

        }


       
        


    }
}


